package scau.hotel.hotel_model.controller;

/**
 * 公共返回对象
 */


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class RespBean {

    private long code;
    private String message;
    private Object data;

    //成功返回结果：通用
    public static RespBean success(){
        return new RespBean(RespBeanEnum.SUCCESS.getCode(),RespBeanEnum.SUCCESS.getMessage(),null);
    }

    //成功返回结果：通用，带data
    public static RespBean success(Object data){
        return new RespBean(RespBeanEnum.SUCCESS.getCode(),RespBeanEnum.SUCCESS.getMessage(),data);
    }

    //成功返回结果：自定义信息，带data
    public static RespBean success(String message, Object data){
        return new RespBean(RespBeanEnum.SUCCESS.getCode(),message,data);
    }

    //成功返回结果：自定义信息
    public static RespBean success(String message){
        return new RespBean(RespBeanEnum.SUCCESS.getCode(),message,null);
    }

    //失败返回结果：失败枚举，自定义信息
    public static RespBean error(RespBeanEnum respBeanEnum,String message){
        return new RespBean(respBeanEnum.getCode(),message,null);
    }

    //失败返回结果：失败枚举
    public static RespBean error(RespBeanEnum respBeanEnum){
        return new RespBean(respBeanEnum.getCode(),respBeanEnum.getMessage(),null);
    }

    //失败返回结果：失败枚举，带data
    public static RespBean error(RespBeanEnum respBeanEnum,Object data){
        return new RespBean(respBeanEnum.getCode(),respBeanEnum.getMessage(),data);
    }
}
